package com.ckzp.demo;

import com.jfinal.server.undertow.UndertowServer;
import com.jfinal.server.undertow.WebBuilder;
import io.undertow.server.HandlerWrapper;
import io.undertow.server.HttpHandler;
import io.undertow.server.handlers.DisallowedMethodsHandler;
import io.undertow.util.HttpString;

import java.util.function.Consumer;

/**
 * Created by 51594 on 2023/3/7.
 */
public class App {

    public static void main(String[] args) {
        // jetty
        // JFinal.start("WebRoot", 80, "/", 5);

        // Undertow
        // Undertow 是为嵌入而生的 Web Server，web.xml 已被抛弃，所以无法通过 web.xml 配置 web 组件。
        UndertowServer undertow = UndertowServer.create(DemoConfig.class);
        undertow.configWeb(new Consumer<WebBuilder>() {
            @Override
            public void accept(WebBuilder builder) {
                builder.addFilterUrlMapping("jfinal", "/admin9527/*");
            }
        });

        // undertow.onDeploy((classLoader, deploymentInfo) -> {
        //// deploymentInfo.insertFilterUrlMapping(0, "shiro", "/*",
        // DispatcherType.REQUEST);
        // for (FilterMappingInfo fm : deploymentInfo.getFilterMappings()) {
        // System.out.println(fm.getFilterName());
        // }
        // });

        // 禁用 HTTP TRACE / TRACK Methods

        undertow.start();
    }

}
